package com.shaoyu.elasticsearch.entity;


import com.shaoyu.elasticsearch.util.CommonUtil;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class ElasticsearchIndex {

    //ElasticSearchIndexRepository extends JpaRepository<ConfigUser, String>
    @Id
    private String id = CommonUtil.getUUID();
    @Column(name = "index_index")
    private String index;
    @Column(name = "index_type")
    private String type;
    @Column(name = "index_explain")
    private String explain;

    public String getId() {
        return id;
    }

    public ElasticsearchIndex setId(String id) {
        this.id = id;
        return this;
    }

    public String getIndex() {
        return index;
    }

    public ElasticsearchIndex setIndex(String index) {
        this.index = index;
        return this;
    }

    public String getType() {
        return type;
    }

    public ElasticsearchIndex setType(String type) {
        this.type = type;
        return this;
    }

    public String getExplain() {
        return explain;
    }

    public ElasticsearchIndex setExplain(String explain) {
        this.explain = explain;
        return this;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj!=null&&obj instanceof ElasticsearchIndex){
            return ((ElasticsearchIndex)obj).getIndex().equalsIgnoreCase(this.getIndex())&&
                    ((ElasticsearchIndex)obj).getType().equalsIgnoreCase(this.getType());
        }
        return false;
    }
}
